/**
 * FileName:         VideosEyeServiceImpl.java
 * @Description:     TODO
 * @author:            zl
 * @version            V1.0
 * Createdate:      2019年1月11日     下午3:12:56
 * Copyright:       
 * Company           CY.
 * All rights Reserved, Designed By crane-yuan

 * Modification  History:
 * Date         Author        Version        Discription
 * ---------------------------------------------------------------------------
 * 2019年1月11日     crane-yuan       1.0             1.0

 * Why & What is modified:

 */
package com.Brewing.springboot.service.TpVideosEye;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.Brewing.springboot.common.PagedResult;
import com.Brewing.springboot.entity.TpVideosEye.TpVideosEye;
import com.Brewing.springboot.entity.TpVideosEye.TpVideosEyeExample;
import com.Brewing.springboot.entity.TpVideosEye.TpVideosEyeExample.Criteria;
import com.Brewing.springboot.mapper.TpVideosEyeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Company: </p>
 * @author  庄磊
 * @date	2019年1月11日 下午3:12:56 
 * @version 1.0
 */
@Service
public class VideosEyeServiceImpl implements VideosEyeService{
	@Autowired
	private TpVideosEyeMapper tpVideosEyeMapper;
	/**
	 * <p>Title: getVideos</p>
	 */ 
	@Override
	public PagedResult getVideos(String categoriesId, Integer page, Integer pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(page,pageSize);
		TpVideosEyeExample example = new TpVideosEyeExample();
		Criteria criteria = example.createCriteria();
		criteria.andCategoriesIdEqualTo(categoriesId);
		List<TpVideosEye> list = tpVideosEyeMapper.selectByExample(example);
		PageInfo<TpVideosEye> pageList = new PageInfo<>(list);
		PagedResult pagedResult = new PagedResult();
		pagedResult.setTotal(pageList.getPages());
		pagedResult.setRows(list);
		pagedResult.setPage(page);
		pagedResult.setRecords(pageList.getTotal());
		return pagedResult;
	}
	
	@Override
	public PagedResult getEqVideos(String id, String categoriesId, Integer page, Integer pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(page,pageSize);
		TpVideosEyeExample example = new TpVideosEyeExample();
		Criteria criteria = example.createCriteria();
		criteria.andCategoriesIdEqualTo(categoriesId);
		criteria.andIdNotEqualTo(id);
		List<TpVideosEye> list = tpVideosEyeMapper.selectByExample(example);
		PageInfo<TpVideosEye> pageList = new PageInfo<>();
		PagedResult pagedResult = new PagedResult();
		pagedResult.setTotal(pageList.getPages());
		pagedResult.setRows(list);
		pagedResult.setPage(page);
		pagedResult.setRecords(pageList.getTotal());
		return pagedResult;
	}
	

}
